package com.agileboot.domain.airport.report.model;

import com.agileboot.common.exception.ApiException;
import com.agileboot.common.exception.error.ErrorCode;
import com.agileboot.domain.airport.report.db.SirReportEntity;
import com.agileboot.domain.airport.report.db.SirReportService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

/**
 * 安全信息工厂类
 */
@Component
@RequiredArgsConstructor
public class ReportModelFactory {

    @Qualifier("sirReportServiceImpl")
    private final SirReportService reportService;

    public ReportModel loadById(Long reportId) {
        SirReportEntity entity = reportService.getById(reportId);
        if (entity == null) {
            throw new ApiException(ErrorCode.Business.COMMON_OBJECT_NOT_FOUND, reportId, "安全信息");
        }
        return new ReportModel(entity, reportService);
    }

    public ReportModel create() {
        return new ReportModel(reportService);
    }

}
